import axios from '@/libs/api.request'
/* 项目下 数据结构、规则、决策流 资源请求接口 */

// 取项目所属资源基本信息列表
export const queryResourceBaseInfoApi = (path, params) => axios.request({
  url: `project/${path.projectId}/resource`,
  method: 'get',
  params
})

// 为项目创建一个新的资源（基本信息）注：“输入数据” “输出数据” “决策流” 随创建项目自动创建基本信息
export const addResourceBaseInfoApi = (params, data) => axios.request({
  url: `project/${params.projectId}/resource`,
  method: 'post',
  data
})

// 获取指定项目所属资源的基本信息
export const getResourceBaseInfoByIdApi = params => axios.request({
  url: `project/${params.projectId}/resource/${params.resId}`,
  method: 'get'
})

// 更新项目下指定资源的基本信息
export const updateResourceBaseInfoByIdApi = (params, data) => axios.request({
  url: `project/${params.projectId}/resource/${params.resId}`,
  method: 'put',
  data
})

// 删除项目下指定资源
export const deleteResourceBaseInfoByIdApi = params => axios.request({
  url: `project/${params.projectId}/resource/${params.resId}`,
  method: 'delete'
})

// 获取项目下指定资源的最新内容
export const queryResourceContentByIdApi = params => axios.request({
  url: `project/${params.projectId}/resource/${params.resId}/content`,
  method: 'get'
})

// 测试项目下指定资源的最新版内容
export const testResourceContentByIdApi = (params, data) => axios.request({
  url: `project/${params.projectId}/resource/${params.resId}/content`,
  method: 'post',
  data
})

// 获取指定资源的输入字段列表
export const getResourceTestInputDataApi = params => axios.request({
  url: `project/${params.projectId}/resource/${params.resId}/input`,
  method: 'get'
})

// 保存项目下指定资源的最新版内容
export const updateResourceContentByIdApi = (params, data) => axios.request({
  url: `project/${params.projectId}/resource/${params.resId}/content`,
  method: 'put',
  data
})

// 衍生函数语法验证
export const verification = data => axios.request({
  url: 'ids/data/derivative/valid',
  method: 'post',
  data
})
